Cascading Spin List

Description

It is possible to make cascading spin lists using Alpha Anywhere. In this scenario you have two spin-list controls with the selection in the first spin-list control determining the choices that will appear in the second spin-list control.

Creating a Cascading Spin List

  1. Open the UX Builder. In the Data Controls menu select a [Spin List] control to add a spin control to the component. Give the control the name spinCountries

    images/cas.png
  2. Add a second spin control to the component. Give it the name spinCities

    images/cas2.png
    The two added spin list controls
  3. Go to the UX Properties page. Scroll down to the Data Series section and click on the next to the Data series property.

    images/cas3.png
  4. In the Data Series Definition dialog click the 'Add Data Series' button.

    images/cas4.png
  5. Name the data series 'SeriesCountries' and click OK.

    images/cas5.png
  6. With the SeriesCountries data series highlighted, click the "Edit Series Definition" button.

    images/cas6.png
  7. In the Data Series Builder choose SQL as the Data Source Type.

    images/cas7.png
  8. With SQL set as the Data Source, look at the SQL Data Source properties.

    images/cas8.png
  9. Next to the Connection string property click the button and set the connection string to the Northwind database.

    images/cas9.png
  10. Click the next to the "Table name"" property and set this to 'Customers'

    images/cas10.png
  11. Click the next to the "Field list"" property and set it to Country

    images/cas11.png
  12. Set the "Order" property to Country.

    images/cas12.png
  13. Check the "Distinct" property checkbox. The SQL Data Source section should now look like this:

    images/cas13.png
  14. Still in the Data Series Builder, find the Arguments section and click the next to the Arguments property.

    images/cas14.png
  15. Click Insert New Argument. Define an Argument called whatCountry

    images/cas15.png
  16. Set the Value property of the argument to be spinCountries

    images/cas16.png
  17. Click OK and OK again.

  18. Back in the Data Series Definition dialog click 'Add Data Series' to define a second Data Series. Name this data series "SeriesCities"

    images/cas17.png
  19. Highlight the SeriesCities Data Series and click 'Edit Series Definition'

  20. Under Data Source Type select SQL again.

  21. Go to the SQL Data Source section and again select the Northwind database as the 'Connection string'.

  22. Set the Table name property to Customers again.

  23. Set the Field list property to City

    images/cas18.png
  24. For the Filter property put the following

    Country =:whatCountry
    images/cas19.png
    The Filter property
  25. Set the Order property to "City".

  26. Finally, Check Distinct. The SQL Data Source list for the SeriesCities data source should look like this:

    images/cas20.png
  27. Click OK and OK again to get back to the UX Property page.

  28. Open the UX Controls page. Highlight the spinCountries control, then view the Spin List Properties section of the Properties menu. Find the "Method for defining list" property and change its setting to 'Data Series'.

    images/cas21.png
  29. This will make available the "Data series" mapping property. Click the box next to the Data series mapping property.

    images/cas22.png
  30. Set the spinCountries control's Display value and Stored value to be "SeriesCountries.Country".

    images/cas23.png
  31. Click OK and OK.

  32. Go back to the UX Controls page. Highlight the spinCities control. Go to the Spin List Properties for this control and change the "Method for defining list" property to 'Data Series' again.

  33. Click the next to the Data series mapping property.

  34. Set spinCities Display value and Stored value to be "SeriesCities.City".

    images/cas24.png
  35. Click OK and OK.

  36. All that is left now is the need to automatically refresh the control. Highlight the spinCountries control and click the button next to the OnSelect property

    images/cas25.png
  37. In the spinCountries control add this code to the OnSelect property. This will refresh the data series in SeriesCities after a 10 millisecond delay

    setTimeout(function() { {dialog.object}.refreshDataSeries('seriesCities')},10);
    The timeout prevents the refresh from starting before the spinCountries control has obtained the correct value.
  38. Now run the component in Live View. Change the country on the top spin-list and the selection of cities on the lower spin-list will update to match the country.

    • images/cas26.png
      Cities with Canada selected
    • images/cas27.png
      Cities when France is selected
    • images/cas28.png
      Cities with Spain selected

Videos

To learn more, check out the videos below:

Spin List Control

The Spin List control is ideal for mobile applications. It is an alternative to a Dropdown control or an Edit-combo textbox. It can be used when the user needs to select from a pre-defined list of values.

Download Component